home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / WindowNode.cpp < prev    next >
Text File  |  1997-02-20  |  3KB  |  113 lines

  1. /*
  2.  *  File:       WindowNode.cpp
  3.  *  Summary:       A node representing a window resource for use in a THierarchicalTable.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->     1/17/96    JDJ        Created
  12.  */
  13.  
  14. #include "WindowNode.h"
  15.  
  16. #include <ZDocWindow.h>
  17. #include "ZHandleStream.h"
  18. #include <ZHierarchicalTable.h>
  19.  
  20. #include "ViewContainer.h"
  21. #include "WindowPicker.h"
  22. #include "WindowProxy.h"
  23.  
  24.  
  25. // ===================================================================================
  26. //    class CWindowNode
  27. // ===================================================================================
  28.  
  29. //---------------------------------------------------------------
  30. //
  31. // CWindowNode::~CWindowNode
  32. //
  33. //---------------------------------------------------------------
  34. CWindowNode::~CWindowNode()
  35. {
  36. }
  37.  
  38.  
  39. //---------------------------------------------------------------
  40. //
  41. // CWindowNode::CWindowNode (THierarchicalTable*, CResourceMap*)
  42. //
  43. //---------------------------------------------------------------
  44. CWindowNode::CWindowNode(THierarchicalTable* table, CResourceMap* rsrcMap) : CResourceNode(table, rsrcMap)
  45. {
  46. }
  47.  
  48.  
  49. //---------------------------------------------------------------
  50. //
  51. // CWindowNode::CWindowNode (THierarchicalTable*, TSubNode*, CResourceMap*, ResID)
  52. //
  53. //---------------------------------------------------------------
  54. CWindowNode::CWindowNode(THierarchicalTable* table, TSubNode* parent, CResourceMap* rsrcMap, ResID id) : CResourceNode(table, parent, rsrcMap, id)
  55. {
  56. }
  57.  
  58.  
  59. //---------------------------------------------------------------
  60. //
  61. // CWindowNode::Make
  62. //
  63. //---------------------------------------------------------------
  64. CResourceNode* CWindowNode::Make(TSubNode* parent, ResID id)
  65. {
  66.     return new CWindowNode(mTable, parent, mRsrcMap, id);
  67. }
  68.  
  69.  
  70. //---------------------------------------------------------------
  71. //
  72. // CWindowNode::EditResource
  73. //
  74. //---------------------------------------------------------------
  75. void CWindowNode::EditResource()
  76. {
  77.     TDocWindow* docWind = dynamic_cast<TDocWindow*>(mTable->GetTopView());
  78.     
  79.     THandle data = mRsrcMap->GetResourceData(mID);
  80.  
  81.     TWindow* window = nil;
  82.  
  83.     CViewContainer* container = CViewContainer::GetContainer('Wind', mID);
  84.     if (container != nil) {
  85.         TView* top = container->GetTopView();
  86.         window = dynamic_cast<TWindow*>(top);
  87.         window->Select();
  88.         
  89.     } else if (data.GetSize() == 0) {
  90.         window = ::PickWindow(docWind->GetDoc());
  91.         if (window != nil) {
  92.             (void) new CViewContainer(window, mRsrcMap, mID);
  93.             window->HandleOpen();
  94.         }
  95.         
  96.     } else {
  97.         CWindowProxy::msUseProxy = true;
  98.         
  99.         TInHandleStream stream(data);    
  100. //        window = CDialogBoxProxy::Create(stream, docWind->GetDoc());
  101.         window = TWindow::Create(stream, docWind->GetDoc());
  102.         
  103.         container = dynamic_cast<CViewContainer*>(window->FindSubPane("CViewContainer"));
  104.         ASSERT(container != nil);
  105.         
  106.         container->SetResourceID(mRsrcMap, mID);
  107.         
  108.         window->HandleOpen();
  109.     }
  110. }
  111.  
  112.  
  113.